package com.shengyo.model.service.impl;

import java.util.List;

import com.shengyo.model.bean.Product;
import com.shengyo.model.dao.IProductDAO;
import com.shengyo.model.service.IProductService;




public class ProductServiceImpl implements IProductService{

	public IProductDAO productDAO;
	@Override
	public void delete(int id) {
		Product product = (Product)productDAO.findById(id);
		if (product != null){
			productDAO.delete(product);
	}
	}
	@Override
	public List<?> findAll() {
		return productDAO.findAll();
	}

	/*
	public Pages findAll(Pages pages) {
		if (pages.getTotalRecord() < 0){
			pages.setTotalRecord(productDAO.getTotal());
			pages.countPages();
		}
		pages.setDataList(productDAO.findAll(pages.getFirstRecord(), pages.getPageNum()));
		return pages;
	}
   */
	@Override
	public Product findById(int id) {
		return (Product) productDAO.findById(id);
	}

	@Override
	public Product saveOrUpdate(Product product) {
        product = (Product)productDAO.save(product);
		return product;
	}
	@Override
	public Product findByProductUrl(String url) {
		return productDAO.findByUrl(url);
	}

}
